<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@ page import="BLL.*"%>
<%@ page import="Model.*"%>
<%@ page import="java.io.*"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>更改头像</title>
</head>
<body>
<%	String id=request.getParameter("id");
	FileItemFactory factory=new DiskFileItemFactory();   //使用了多态
	ServletFileUpload sfu=new ServletFileUpload(factory);
	response.setCharacterEncoding("utf-8");
	List<FileItem> list=sfu.parseRequest(request);
	String fileName=null;
	String filePath=null;
	for(FileItem file:list){
		if(file.isFormField()==false){  //判断 是不是普通的表单项 
			//后台的校验   不符合格式要求的，剁了   .jpg .png .jpeg
			String uploadFileName=file.getName(); //获取到上传过来的文件名	
			filePath="E:\\EclipseProject\\Two\\XiaoGao\\WebContent\\Upload\\"+file.getName();
			fileName=file.getName();
			file.write(new File(filePath));//存入本机
		}
	}%>
<div><img  src="Upload/<%= fileName %>"></div><br>
<a href="updatePPP.jsp?id=<%=id%>&file=<%=filePath%>">确认更行</a>
</body>
</html>